package cn.rkylin.oms.refund.vo;

import java.util.Date;

import org.apache.commons.lang.StringUtils;

import cn.rkylin.oms.common.utils.DateUtil;
import cn.rkylin.oms.refund.domain.Refund;  

/**
 * 
 * @author jipengcheng
 *
 */
public class RefundVO extends Refund {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5280096482281013727L;
	private static final String STATUS_ECORDERSHOW = "<span class=\"fa fa-chevron-down\" ecRefundId=\"%s\"></span>";   	//明细显示箭头
	private static final String OUTDATETIMESHOW = "<span class='badge badge-red'> </span>";   							//超时标识
	private static final String EXCEPTION_FLAG = "<span class='badge badge-red'> </span>";								//异常标识
	private static final String OUTDAY = "3";
	
	
	/**
     * 搜索条件
     */
    private String searchCondition;
    
    /**
     * 高级检索用
     * @return
     */
    private String ecItemCode;		//平台商品编码
    private String ecSkuCode;		//平台规格编码
    private String dateStart;		//超时开始时间
	private String dateEnd;			//超时结束时间
	
	/**
     * 排序
     */
    private String orderBy;
    
    /**
     * 明细显示html
     */
    private String ecRefundItemShow;
    
    //异常标识
  	private String exceptionType="";
  	//超时标识
  	private String outTimeshow = "";
  	//退款状态
  	private String refundStatusNm = "";
  	//
  	private String refundTradeStatus = "";
  	
  	private Integer countWaitAgree;
  	private Integer countWaitSend;
  	private Integer countWaitRecive;
  	private Integer countWaitReject;
  	private Integer countOver;
  	//退款关闭的记录数
  	private Integer countCancel;

	public Integer getCountWaitAgree() {
        return countWaitAgree;
    }

    public void setCountWaitAgree(Integer countWaitAgree) {
        this.countWaitAgree = countWaitAgree;
    }

    public Integer getCountWaitSend() {
        return countWaitSend;
    }

    public void setCountWaitSend(Integer countWaitSend) {
        this.countWaitSend = countWaitSend;
    }

    public Integer getCountWaitRecive() {
        return countWaitRecive;
    }

    public void setCountWaitRecive(Integer countWaitRecive) {
        this.countWaitRecive = countWaitRecive;
    }

    public Integer getCountWaitReject() {
        return countWaitReject;
    }

    public void setCountWaitReject(Integer countWaitReject) {
        this.countWaitReject = countWaitReject;
    }

    public Integer getCountOver() {
		return countOver;
	}

	public void setCountOver(Integer countOver) {
		this.countOver = countOver;
	}

	public Integer getCountCancel() {
		return countCancel;
	}

	public void setCountCancel(Integer countCancel) {
		this.countCancel = countCancel;
	}

	public String getRefundTradeStatus() {
		return FinalValueMap.TRADE_STATUS.get(this.getEcTradeStus());
	}

	public void setRefundTradeStatus(String refundTradeStatus) {
		this.refundTradeStatus = refundTradeStatus;
	}

	public String getRefundStatusNm() {
		return FinalValueMap.REFUND_STATUS.get(this.getRefundStatus());
	}

	public void setRefundStatusNm(String refundStatusNm) {
		this.refundStatusNm = refundStatusNm;
	}

	public String getOutTimeshow() {
		try {
			if (this.getRefundTimeout()!=null && DateUtil.daysBetween(new Date(),this.getRefundTimeout()) < Integer.valueOf(OUTDAY).intValue()){
				return OUTDATETIMESHOW;
			} else {
				return outTimeshow;
			}
		} catch (Exception e) {
			e.printStackTrace();
			return outTimeshow;
		}
	}

	public void setOutTimeshow(String outTimeshow) {
		this.outTimeshow = outTimeshow;
	}

	public String getExceptionType() {
		if (StringUtils.isNotBlank(this.getErrDesc())){
			return EXCEPTION_FLAG;
		} else {
			return exceptionType;
		}
	}

	public void setExceptionType(String exceptionType) {
		this.exceptionType = exceptionType;
	}
	
    public String getEcRefundItemShow() {
		return String.format(STATUS_ECORDERSHOW, this.getEcRefundId()).toString();
	}

	public void setEcRefundItemShow(String ecRefundItemShow) {
		this.ecRefundItemShow = ecRefundItemShow;
	}

	public String getOrderBy() {
        // 此字段需要防止sql注入
        return orderBy == null ? null : orderBy.replaceAll(".*([';]+|(--)+).*", " ");
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }
    
	public String getDateStart() {
		return dateStart;
	}

	public void setDateStart(String dateStart) {
		this.dateStart = dateStart;
	}

	public String getDateEnd() {
		return dateEnd;
	}

	public void setDateEnd(String dateEnd) {
		this.dateEnd = dateEnd;
	}

	public String getEcItemCode() {
		return ecItemCode;
	}

	public void setEcItemCode(String ecItemCode) {
		this.ecItemCode = ecItemCode;
	}

	public String getEcSkuCode() {
		return ecSkuCode;
	}

	public void setEcSkuCode(String ecSkuCode) {
		this.ecSkuCode = ecSkuCode;
	}

	public String getSearchCondition() {
		return searchCondition;
	}

	public void setSearchCondition(String searchCondition) {
		this.searchCondition = searchCondition;
	}
    
}
